<template>
  <view class="cart-container">
    <view class="cart-items">
      <view v-for="item in cartItems" :key="item.id" class="cart-item">
        <image :src="item.image" class="item-image" />
        <view class="item-info">
          <text class="item-name">{{ item.name }}</text>
          <text class="item-price">¥{{ item.price }}</text>
        </view>
        <view class="quantity-control">
          <button @click="decreaseQuantity(item)">-</button>
          <text class="quantity">{{ item.quantity }}</text>
          <button @click="increaseQuantity(item)">+</button>
        </view>
      </view>
    </view>

    <view class="checkout-section">
      <view class="total">总计: ¥{{ totalPrice }}</view>
      <button class="pay-btn" @click="wechatPay">微信支付</button>
    </view>
  </view>
</template>

<script>
  export default {
    data() {
      return {
        cartItems: [], // 从vuex或storage中获取
        totalPrice: '',
      }
    },
    methods: {
      wechatPay() {
        uni.requestPayment({
          provider: 'wxpay',
          orderInfo: {}, // 后端生成的支付信息
          success: () => {
            uni.showToast({
              title: '支付成功'
            })
          }
        })
      }
    }
  }
</script>

<style lang="scss">

</style>